/**
*@Author: QWP
*@Description: 获取程序版本号
*@Params: init 是否初始进入时加载
*@Date 2024-06-17 09:14
*/
import { useHomeStore } from "@/store"
import axios from "axios"
import { numberC } from '@/util/common'
export const checkUpdate = (init) => {
  return new Promise((resolve, reject) => {
    axios.get(window.origin + '/config/v.js').then(res => {
      let v = `${res.data}`.replace('v=', '')
      if(init == true) {
        store.commit('homeStore/setVersion', v)
      }
      else {
        if(numberC(v) > numberC(store.getters['homeStore/getVersion'])) {
          store.commit('homeStore/setVersion', v)
          resolve(true)
        }
      }
    })
  })
}